#ifndef     __SENSOR_H
#define     __SENSOR_H

#include <stdint.h>
#include "../utils/nocopyable.h"
#include "../utils/object.h"

namespace heat_driver {

class Sensor : public Object<Sensor>, private NoCopyable {

public:
    void init();

    uint16_t adc_value();

    bool is_stir_top() {
        return 0x00 != (read() & 0x04);
    }

    bool is_stir_bottom() {
        return 0x00 != (read() & 0x08);
    }

    bool is_hold_left() {
        return 0x00 != (read() & 0x10);
    }

    bool is_hold_right() {
        return 0x00 != (read() & 0x20);
    }

    bool is_film_up() {
        return 0x00 != (read() & 0x40);
    }

    bool is_film_down() {
        return 0x00 != (read() & 0x80);
    }

    uint16_t flow_count();
    void flow_reset();
    uint16_t flow();

    bool is_leak();
    bool is_waste_full(); // 废水
    bool is_tank_low();
    bool is_tank_high();
    bool is_hot_low();
    bool is_hot_high();

    int16_t steam_temp() { return m_steam_temp; }
    int16_t water_temp() { return m_water_temp; }
    
    bool is_steam_temp_ok() { return m_steam_temp_ok; }
    bool is_water_temp_ok() { return m_water_temp_ok; }

    void read_temp();

    static uint8_t read();

private:
    int16_t m_steam_temp = 0;
    bool m_steam_temp_ok = false;
    int16_t m_water_temp = 0;
    bool m_water_temp_ok = false;
};

extern Sensor sensor;

}


#endif
